﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _20.GenerateAllVariations
{
    class Variations
    {
        static void GetVariations(int[] arr,int index,int n)
        {
            if (index==arr.Length)
            {
                for (int i = 0; i < arr.Length; i++)
                {
                    Console.Write(arr[i]+" ");
                }
                Console.WriteLine();
            }
            else
            {
                for (int i = 1; i <= n; i++)
                {
                    arr[index] = i;
                    GetVariations(arr, index + 1, n);
                }
            }
        }
        static void Main(string[] args)
        {
            Console.WriteLine("Enter N and K to see all the variations of K elements from the set [1..N] ");
            Console.Write("Enter N=");
            int n = int.Parse(Console.ReadLine());
            Console.Write("Enter K=");
            int k = int.Parse(Console.ReadLine());
            int[] variations = new int[k];
            GetVariations(variations, 0, n);
        }
    }
}
